package com.cityeye.entity;

import java.sql.Time;

/**
 * User entity. @author MyEclipse Persistence Tools
 */

public class Loginuser extends com.cityeye.util.IEntity implements
		java.io.Serializable {

	public static final int ROLE_NORMAL = 0;
	public static final int ROLE_OPERATOR = 9;
	public static final int ROLE_ADMIN = 10;
	public static final int ROLE_GUEST = 100;
	// Fields

	private Integer id;
	private Department department;
	private String name;
	private String password;
	private Integer valid = 1;
	private Time lastlogin;
	private Integer role = 100;

	// Constructors

	/** default constructor */
	public Loginuser() {
	}

	/** minimal constructor */
	public Loginuser(Integer id, String name, Integer valid, Integer role) {
		this.id = id;
		this.name = name;
		this.valid = valid;
		this.role = role;
	}

	/** full constructor */
	public Loginuser(Integer id, Department department, String name,
			String password, Integer valid, Time lastlogin, Integer role) {
		this.id = id;
		this.department = department;
		this.name = name;
		this.password = password;
		this.valid = valid;
		this.lastlogin = lastlogin;
		this.role = role;
	}

	// Property accessors

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Department getDepartment() {
		return this.department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getValid() {
		return this.valid;
	}

	public void setValid(Integer valid) {
		this.valid = valid;
	}

	public Time getLastlogin() {
		return this.lastlogin;
	}

	public void setLastlogin(Time lastlogin) {
		this.lastlogin = lastlogin;
	}

	public Integer getRole() {
		return this.role;
	}

	public void setRole(Integer role) {
		this.role = role;
	}

	public boolean isGuest() {
		return (role == ROLE_GUEST && getDepartment() == null);
	}

	public boolean isAdmin() {
		return (role == ROLE_ADMIN);
	}

	public boolean isOperator() {
		return (role == ROLE_OPERATOR);
	}

	public boolean isQuAdmin() {
		return (role == ROLE_NORMAL && getDepartment() != null && getDepartment()
				.getType() == Department.TYPE_QU);
	}

	public boolean isJdAdmin() {
		return (role == ROLE_NORMAL && getDepartment() != null && getDepartment()
				.getType() == Department.TYPE_JIEDAO);
	}
	
	public boolean isQuGuest() {
		return (role == ROLE_GUEST && getDepartment() != null && getDepartment()
				.getType() == Department.TYPE_QU);
	}

	public boolean isJdGuest() {
		return (role == ROLE_GUEST && getDepartment() != null && getDepartment()
				.getType() == Department.TYPE_JIEDAO);
	}	
}